package exercise4;

public class Exercise09_01 {
    public static void main(String []args){
        Rectangle rectangle_1=new Rectangle(4,40);
        Rectangle rectangle_2=new Rectangle(3.5,35.9);

        System.out.println("第一个矩形的宽是："+rectangle_1.width+",长是 "+rectangle_1.height);
        System.out.println("面积是 "+rectangle_1.getArea()+" ,周长是 "+rectangle_1.getPerimeter());
        System.out.println();
        System.out.println("第二个矩形的宽是："+rectangle_2.width+",长是 "+rectangle_2.height);
        System.out.println("面积是 "+rectangle_2.getArea()+" ,周长是 "+rectangle_2.getPerimeter());
    }
}

class Rectangle{
    double width=1;
    double height=1;

    Rectangle(){
    }

    Rectangle(double new_width,double new_height){
        width=new_width;
        height=new_height;
    }

    public double getArea(){
        return width*height;
    }

    public double getPerimeter(){
        return 2 * (width + height);
    }

}
